import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ReduceVO, ReduceForm, ReduceQuery } from '@/api/farm/reduce/types';
import {UnwrapRef} from "vue";

/**
 * 查询减少记录列表
 * @param query
 * @returns {*}
 */

export const listReduce = (query?: ReduceQuery): AxiosPromise<ReduceVO[]> => {
  return request({
    url: '/farm/reduce/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询减少记录详细
 * @param id
 */
export const getReduce = (id: string | number): AxiosPromise<ReduceVO> => {
  return request({
    url: '/farm/reduce/' + id,
    method: 'get'
  });
};

/**
 * 新增减少记录
 * @param data
 */
export const addReduce = (data: ReduceForm) => {
  return request({
    url: '/farm/reduce',
    method: 'post',
    data: data
  });
};

/**
 * 修改减少记录
 * @param data
 */
export const updateReduce = (data: UnwrapRef<ReduceForm>) => {
  return request({
    url: '/farm/reduce',
    method: 'put',
    data: data
  });
};

/**
 * 删除减少记录
 * @param id
 */
export const delReduce = (id: string | number | Array<string | number>) => {
  return request({
    url: '/farm/reduce/' + id,
    method: 'delete'
  });
};
/**
 * 默认标题
 */
export const defaultTitle = () => {
  return request({
    url: `/farm/reduce/title`,
    method: 'get'
  });
};
/**
 * 审核操作
 * @param data
 */
export const auditReduceApi = (data: any) => {
  return request({
    url: `/farm/reduce/audit`,
    method: 'put',
    data: data
  });
};
